home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Nebula 2
/
Nebula Two.iso
/
SourceCode
/
AlexNeXTSTEPSource
/
Source
/
Chapter4_AppKit
/
AppKitDemo.m
< prev
next >
Wrap
Text File
|
1995-06-12
|
1KB
|
47 lines
#import <appkit/appkit.h>
// a program to demonstrate how to display
// a window and a menu with a Quit option
void main(void)
{
// create an application object
// to establish connection to
// Window Server
id NXApp = [Application new];
id theWindow;
id theMenu;
id theMenuCell;
// create buffered window at default
// location with minituarize button
// and title bar
theWindow = [ [Window alloc]
initContent:NULL
style: NX_RESIZEBARSTYLE
backing:NX_BUFFERED
buttonMask:NX_MINIATURIZEBUTTONMASK
defer:YES];
// create the menu
theMenu = [ [Menu alloc]
initTitle: "AppKitDemo"];
// create the menu option
theMenuCell = [theMenu addItem:"Quit"
action:@selector(terminate:)
keyEquivalent:'q'];
// set NXApp as target of the menucell
[theMenuCell setTarget:NXApp];
// resize menu to accomodate menu option
[theMenu sizeToFit];
[NXApp setMainMenu:theMenu];
// send the window to the front
// and display it
[theWindow makeKeyAndOrderFront:nil];
// go into event loop to wait for events
[NXApp run];
}